package com.qf.controller;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.qf.entity.Address;
import com.qf.service.IAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/addressController")
public class AddressController {

    @Autowired
    private IAddressService addressService;

    @RequestMapping("/getAddressListByUserId/{id}")
    public List<Address> getAddressListByUserId(@PathVariable("id") Integer id) {
        EntityWrapper entityWrapper = new EntityWrapper();
        entityWrapper.eq("uid", id);
        return addressService.selectList(entityWrapper);
    }

    @RequestMapping("/getAddressById/{id}")
    public Address getAddressById(@PathVariable("id") Integer id) {
        EntityWrapper entityWrapper = new EntityWrapper();
        entityWrapper.eq("id", id);
        return addressService.selectOne(entityWrapper);
    }
}
